package com.example.springinit2.thread0;

import java.util.concurrent.TimeUnit;

public class TicketWindow extends Thread {
  private final String name;
  private static final int MAX = 500;
  private static int index = 1;
  public TicketWindow(String name){
    this.name = name;
  }
  @Override
  public void run(){
    while (index <= MAX){
	  System.out.println("柜台"+name+":号码"+(index++));
	}
  }

  public static void main(String[] args) throws InterruptedException {
	TicketWindow ticketWindow = new TicketWindow("一号");
	ticketWindow.start();
	TimeUnit.NANOSECONDS.sleep(1);
	TicketWindow ticketWindow1 = new TicketWindow("二号");
	ticketWindow1.start();
	TicketWindow ticketWindow2 = new TicketWindow("三号");
	ticketWindow2.start();
	TicketWindow ticketWindow3 = new TicketWindow("四号");
	ticketWindow3.start();
  }
}
